<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="function.jsp"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>未读列表</title>
    <link rel="stylesheet" href="/css/public.css?cache=<%=Math.random()%>">
    <link  href="../../hos_manage/images/favicon.ico?cache=<%=Math.random()%>" rel="shortcut icon" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="../../css/palace/message/unread_list.css?a=<%=Math.random()%>">
    <script src="/js/jquery-1.9.1.min.js"></script>
</head>
<body id="app">
<%@ include file="../../header.jsp"%>
<!--内容-->
<div class="containerone">
    <%@ include file="../../left_menu.jsp"%>
    <!--右边内容-->
    <div class="right_cont">
        <!--右边导航下面内容-->
        <div class="tag-detail">
            <div class="title">
                <div class="address-left show-block note">
                    <span class="hover" @click="homePage()">首页</span>
                    <span class="left-distance">></span>
                    <span class="left-distance hover" @click="back()">通知列表</span>
                    <span class="left-distance">></span>
                    <span class="left-distance">未读列表</span>
                </div>
                <div class="create-member" @click="sendAgain()">再次发送</div>
            </div>
            <div class="container">
                <div class="position">
                    <div class="show-block address-book-right">
                        <div class="data-form show-margin-left line">
                            <div class="form-title">
                                <div class="show-block title-width">工号</div>
                                <div class="show-block title-width">姓名</div>
                                <div class="show-block title-width">手机号</div>
                                <div class="show-block title-width">类型</div>
                                <div class="show-block title-width">级别</div>
                                <div class="show-block title-width">状态</div>
                            </div>
                            <div class="form-title bg-white line" v-for="i in unReadList">
                                <div class="show-block title-width" v-html="i.employee_id"></div>
                                <div class="show-block title-width" v-html="i.name"></div>
                                <div class="show-block title-width" v-html="i.phone"></div>
                                <div class="show-block title-width" v-html="i.category_name"></div>
                                <div class="show-block title-width" v-html="i.level_name"></div>
                                <div class="show-block title-width red">未读</div>
                            </div>
                        </div>
                        <pagination :pagecount="page_count" :currentpage="current_page"></pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<dangertip v-if="dangerTipShow" :title="dangerTitle"></dangertip>
<messagetip v-if="messageTipShow" :title="messageTitle"></messagetip>
<delete v-if="deleteShow" :top="delete.top" :title="delete.title" :content="delete.content" :arg="delete.arg"></delete>
</body>
<%@ include file="/components/danger.jsp"%>
<%@ include file="/components/message.jsp"%>
<%@ include file="/components/pagination.jsp"%>
<%@ include file="/components/delete.jsp"%>
<script>
    new Vue({
        el: "#app",
        data: {
            page_count: 0,
            current_page: 1,
            id: "",
            unReadList: [],
            number: "", //成员总数
            selectedNumber: "", //选中的成员的总数
            selectedUser: [],
            deleteShow: false,
            dangerTitle: "",
            dangerTipShow: false,
            messageTitle: "",
            messageTipShow: false,
            delete: {
                top: "",
                title: "",
                content: "",
                arg: {},
            }
        },
        methods: {
            back: function () {
                locationHerf("message_center");
            },
            homePage: function () {
                location.href = "../../index.jsp";
            },
            getData: function () {
                var self = this;
                $.ajax({
                    type: "post",
                    url: location.href,
                    data: {
                        act: "noReadList",
                        hospital: "${user.hospital}",
                        id: self.id,
                        pages: self.current_page + "",
                    },
                    success: function (res) {
                        res = JSON.parse(res);
                        if (res.errcode == "0") {
                            //console.log(res);
                            self.page_count = parseInt(res.data.pages);
                            self.unReadList = res.data.list;
                        }
                    }
                });
            },
            // 选中
            selectUser: function (i) {
                if (this.checkSelectedUser(i)) {
                    this.selectedUser.splice(this.selectedUser.indexOf(i), 1);
                } else {
                    this.selectedUser.push(i);
                }
            },
            // 判断这个人是否被选中
            checkSelectedUser: function(i) {
                return this.selectedUser.filter(function(item) {
                        return item.id == i.id;
                    }).length > 0;
            },
            // 选中或取消所有
            selectAll: function() {
                if (this.selectedAll) {
                    this.selectedUser = [];
                } else {
                    this.selectedUser = this.unReadList.slice(0);
                }
            },
            sendAgain: function () {
                var _this = this;
                this.deleteShow = true;
                this.delete.top = "未读列表";
                this.delete.title = "即将再次发送";
                this.delete.content = "再次发送将会发送给未读的所有人";
                this.delete.arg = function() {
                    $.ajax({
                        type: "post",
                        url: location.href,
                        data: {
                            act: "pushAgain",
                            id: _this.id,
                            hospital: "${user.hospital}",
                        },
                        success: function (res) {
                            res = JSON.parse(res);
                            if (res.errcode == 0) {
                                locationHerf("message_center");
                            } else {
                                _this.danger(res.errmsg);
                            }
                        }
                    });
                }
            },
            danger: function(title) {
                this.dangerTitle = title;
                this.dangerTipShow = true;
            },
            message: function(title) {
                this.messageTitle = title;
                this.messageTipShow = true;
            },
        },
        computed: {
            // 成员总数
            number: function() {
                return this.unReadList.length;
            },
            // 选中的总数
            selectedAllNum: function() {
                return this.selectedUser.length;
            },
            // 如果选中了所有
            selectedAll: function() {
                return this.selectedAllNum == this.number;
            }
        },
        events: {
            changePage: function(i) {
                this.current_page = i.currentpage;
                this.selectedUser = [];
                this.getData();
            },
            deleteCancel: function() {
                this.deleteShow = false;
            },
            deleteSuccess: function(arg) {
                var _this = this;
                this.deleteShow = true;
                this.delete = arg;
            },
            dangerTipOver: function() {
                this.dangerTipShow = false;
            },
            // 消息消失的方法,
            messageTipOver: function() {
                this.messageTipShow = false;
            },
        },
        ready: function () {
            this.id = getHrefParms("unread_list");
            this.getData();
        },
        components: {
            pagination: pagination,
            delete: deleteTip,
            dangertip: dangerTip,
            messagetip: messageTip,
        },
    });
</script>
</html>
